<%@ page language="java" errorPage="/error.jsp" pageEncoding="UTF-8" contentType="text/html; charset=utf-8" %>
<%@include file="/quick/include/common.jsp"%>
<%@include file="/quick/include/commonQuery.jsp"%>
<c:set var="buttons">
    <input type="button" style="margin-right: 5px"   onclick="f_add()" value="<fmt:message key="button.add"/>"/>
    <input type="button" style="margin-right: 5px"   onclick="f_delete()" value="<fmt:message key="button.delete"/>"/>
    <input type="button" style="margin-right: 5px"   onclick="f_cancel()" value="<fmt:message key="button.cancel"/>"/>
    <input type="button" style="margin-right: 5px"   onclick="f_save()" value="<fmt:message key="button.save"/>"/>
    <input type="button" style="margin-right: 5px"   onclick="f_query()" value="<fmt:message key="button.query"/>"/>
    <input type="button" style="margin-right: 5px"   onclick="f_excel()" value="<fmt:message key="button.excel"/>"/>
    <input type="button" style="margin-right: 5px"   onclick="f_back()" value="<fmt:message key="button.back"/>"/>
</c:set>
<div id='toolbar' style="display:none">
<c:out value="${buttons}" escapeXml="false"/>
</div>
<script>
Ext.onReady(function(){
  Ext.get('title').dom.innerHTML='<b><c:out value='${model.parameter.grade}'/>级<c:out value='${model.parameter.majorName}'/>专业<c:out value='${model.parameter.className}'/>学生</b>';
});
Ext.onReady(globalScope._ready);

 

function f_back(){
   location=g_rootPath+'student/schoolClass.html';
}
function f_excel(){
  globalScope._exportExcel();
//  globalScope._excel();
}


function f_add(tableName){
  var grade="<c:out value='${model.parameter.grade}'/>";
  var majorNo="<c:out value='${model.parameter.majorNo}'/>";
  var refid="<c:out value='${model.parameter.REFID}'/>";
  
  f_commonQuery('V_STUDENT',function(recs){
	    Ext.each(recs,function(item){
		      var updtArray=[];
		      var commonQueryGrid=globalScope.grid.get("<c:out value='${model.tableName}'/>");
		      var studentScoreStore=commonQueryGrid.getStore();
			  var newRecord=commonQueryGrid.newRecord('newId');//新建Record
			  newRecord.copyData(item.data); //复制数据
			  commonQueryGrid.stopEditing();//插入Record
	    	  studentScoreStore.insert(0,newRecord); 
	    	  commonQueryGrid.startEditing(0,0);
	    	  newRecord.dirty=true;
	    	  newRecord.modified=newRecord.data;
	    	  if(studentScoreStore.modified.indexOf(newRecord)==-1){
	    	    studentScoreStore.modified.push(newRecord);	
	    	  }	
	    });	
  },
	  function(params){
        Ext.apply(params,{commonQueryCondition:'student_class_conditon',placeValues:"['"+refid+"','"+grade+"','"+majorNo+"']"});	  
	  }); 
}

function f_update(tableName){
  globalScope._update(tableName);
}

function f_delete(tableName){
  globalScope._delete(tableName);
} 

function f_cancel(tableName){
  globalScope._cancel(tableName);
}

function f_save(tableName,url){
  globalScope._simpleSave({tableName:'<c:out value='${model.tableName}'/>',postData:{REFID:'<c:out value='${model.parameter.REFID}'/>'},saveTableName:'T_MAJOR_CLASS_STUDENT',url:'quick/quickJsonProcess.html'});
}

function f_query(tableName){
    globalScope._query(tableName);
}
function f_gotoPage(pageNo,rowsOfPage,pageCount,rowCount,conditoin){
  globalScope._gotoPage({spanName:"g_pageSpan_<c:out value='${model.tableName}'/>",pageNo:pageNo,rowsOfPage:rowsOfPage,pageCount:pageCount,rowCount:rowCount,condition:conditoin,tableName:"<c:out value='${model.tableName}'/>"},{REFID:"<c:out value='${model.parameter.REFID}'/>",grade:"<c:out value='${model.parameter.grade}'/>",majorNo:"<c:out value='${model.parameter.majorNo}'/>"});
}
</script>
